import _Spin from "choerodon-ui/lib/spin";
import _Table from "choerodon-ui/pro/lib/table";
import _DataSet from "choerodon-ui/pro/lib/data-set";
import _Output from "choerodon-ui/pro/lib/output";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
import _isNil from "lodash/isNil";
import _omit from "lodash/omit";
import _isArray from "lodash/isArray";
import _isEmpty from "lodash/isEmpty";
var _excluded = ["fieldCode", "fieldName", "renderOptions", "conditionHeaderDTOs", "renderRule", "colSpan", "conValidDTO"],
    _excluded2 = ["fieldCode", "fieldName", "renderOptions", "visible", "renderRule"];
import React from 'react';
import { Bind } from 'lodash-decorators';
import moment from 'moment';
import template from "../../../../utils/template";
import { queryUnitCustConfig, getComponent, coverConfig, parseProps, transformCompProps, getFieldValueObject, selfValidator } from "./customizeTool";
export default function withCustomize() {
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
      _ref$unitCode = _ref.unitCode,
      unitCode = _ref$unitCode === void 0 ? [] : _ref$unitCode,
      query = _ref.query,
      _ref$manualQuery = _ref.manualQuery,
      manualQuery = _ref$manualQuery === void 0 ? false : _ref$manualQuery;

  return function (Component) {
    var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _class;

    var WrapIndividual = (_dec = Bind(), _dec2 = Bind(), _dec3 = Bind(), _dec4 = Bind(), _dec5 = Bind(), _dec6 = Bind(), _dec7 = Bind(), _dec8 = Bind(), _dec9 = Bind(), _dec10 = Bind(), _dec11 = Bind(), _dec12 = Bind(), (_class = /*#__PURE__*/function (_React$Component) {
      _inherits(WrapIndividual, _React$Component);

      var _super = _createSuper(WrapIndividual);

      function WrapIndividual(props) {
        var _this;

        _classCallCheck(this, WrapIndividual);

        for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
          args[_key - 1] = arguments[_key];
        }

        _this = _super.call.apply(_super, [this, props].concat(args));
        _this.state = {
          custConfig: {},
          loading: true,
          cacheType: {},
          cacheTable: {},
          dataMap: new Map(),
          arrayDataMap: {},
          lastUpdateUnit: ''
        };
        return _this;
      }

      _createClass(WrapIndividual, [{
        key: "setDataMap",
        value: function setDataMap(code, value) {
          this.state.dataMap.set(code, value);
        }
      }, {
        key: "getDataValue",
        value: function getDataValue(code) {
          return this.state.dataMap.get(code) || {};
        }
      }, {
        key: "setArrayDataMap",
        value: function setArrayDataMap(code, value, index) {
          var arrayDataMap = this.state.arrayDataMap;

          if (!arrayDataMap[code]) {
            arrayDataMap[code] = new Map();
          }

          arrayDataMap[code].set(index, value);
        }
      }, {
        key: "getArrayDataValue",
        value: function getArrayDataValue(code, index) {
          var arrayDataMap = this.state.arrayDataMap;

          if (!arrayDataMap[code]) {
            return {};
          }

          return arrayDataMap[code].get(index) || {};
        }
      }, {
        key: "getCacheType",
        value: function getCacheType(code) {
          return this.state.cacheType[code];
        }
      }, {
        key: "getToolFuns",
        value: function getToolFuns() {
          return {
            setArrayDataMap: this.setArrayDataMap,
            getArrayDataValue: this.getArrayDataValue,
            setDataMap: this.setDataMap,
            getDataValue: this.getDataValue,
            getCacheType: this.getCacheType
          };
        }
      }, {
        key: "componentDidMount",
        value: function componentDidMount() {
          if (manualQuery) {
            return;
          }

          this.queryUnitConfig();
        }
      }, {
        key: "queryUnitConfig",
        value: function queryUnitConfig() {
          var _this2 = this;

          var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : query;

          if (unitCode && _isArray(unitCode) && unitCode.length > 0) {
            queryUnitCustConfig(_objectSpread({
              unitCode: unitCode.join(',')
            }, params)).then(function (res) {
              if (res) {
                _this2.setState({
                  custConfig: res || {}
                });
              }
            }).finally(function () {
              _this2.setState({
                loading: false
              });
            });
          } else {
            this.setState({
              loading: false
            });
          }
        }
      }, {
        key: "customizeForm",
        value: function customizeForm() {
          var _this3 = this;

          var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
          var form = arguments.length > 1 ? arguments[1] : undefined;
          var proxyForm = form;
          var _this$state = this.state,
              _this$state$custConfi = _this$state.custConfig,
              custConfig = _this$state$custConfi === void 0 ? {} : _this$state$custConfi,
              _this$state$loading = _this$state.loading,
              loading = _this$state$loading === void 0 ? false : _this$state$loading,
              cacheType = _this$state.cacheType;
          var _options$code = options.code,
              code = _options$code === void 0 ? '' : _options$code,
              readOnly1 = options.readOnly;
          var _proxyForm$props$data = proxyForm.props.dataSet,
              dataSet = _proxyForm$props$data === void 0 ? {
            data: [{}]
          } : _proxyForm$props$data;

          if (loading) {
            proxyForm.props.children = [];
          }

          if (!code || _isEmpty(custConfig[code])) return form;
          var fieldMap = new Map();
          var formChildren = _isArray(proxyForm.props.children) ? proxyForm.props.children : [proxyForm.props.children];
          formChildren.forEach(function (item, seq) {
            if (item.props && item.props.name) {
              fieldMap.set(item.props.name, {
                item: item,
                seq: seq
              });
            }
          });

          var tools = _objectSpread(_objectSpread({}, this.getToolFuns()), {}, {
            code: code
          }); // TODO: c7n不支持字段宽度配置


          var _custConfig$code = custConfig[code],
              _custConfig$code$maxC = _custConfig$code.maxCol,
              maxCol = _custConfig$code$maxC === void 0 ? 3 : _custConfig$code$maxC,
              _custConfig$code$fiel = _custConfig$code.fields,
              fields = _custConfig$code$fiel === void 0 ? [] : _custConfig$code$fiel,
              _custConfig$code$unit = _custConfig$code.unitAlias,
              unitAlias = _custConfig$code$unit === void 0 ? [] : _custConfig$code$unit,
              readOnly2 = _custConfig$code.readOnly;
          var readOnly = readOnly1 || readOnly2;
          var current = dataSet.current || {
            toData: function toData() {
              return {};
            }
          };
          this.setDataMap(code, current.toData());
          var unitData = getFieldValueObject(unitAlias, this.getToolFuns(), code);

          if (!cacheType[code]) {
            // dataSet.tlsUrl = 'cpfm//v1/multi-language';
            cacheType[code] = 'form';
            dataSet.addEventListener('update', function (_ref2) {
              var name = _ref2.name,
                  record = _ref2.record,
                  value = _ref2.value;
              var ds = dataSet.get(0) || {
                toData: function toData() {
                  return {};
                }
              };
              var data = ds.toData();

              _this3.setDataMap(code, data);

              fields.forEach(function (item) {
                var _item$conditionHeader = item.conditionHeaderDTOs,
                    conditionHeaderDTOs = _item$conditionHeader === void 0 ? [] : _item$conditionHeader,
                    fieldCode = item.fieldCode,
                    _item$lovMappings = item.lovMappings,
                    lovMappings = _item$lovMappings === void 0 ? [] : _item$lovMappings,
                    _item$conValidDTO = item.conValidDTO,
                    conValidDTO = _item$conValidDTO === void 0 ? {} : _item$conValidDTO;
                var newFieldConfig = getFieldConfig(_objectSpread({
                  required: item.required,
                  editable: item.editable
                }, coverConfig(conditionHeaderDTOs, tools, ['visible'])));
                var validators = selfValidator(conValidDTO, tools);
                var oldFieldConfig = (dataSet.getField(fieldCode) || {}).pristineProps;
                dataSet.addField(fieldCode, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, oldFieldConfig), newFieldConfig), validators), parseProps(_omit(item, ['width', 'fieldName', 'fieldCode', 'fixed', 'renderOptions', 'conditionHeaderDTOs']), tools, oldFieldConfig)));

                if (lovMappings.length > 0 && name === fieldCode && typeof value === 'object') {
                  lovMappings.forEach(function (i) {
                    record.set(i.targetCode, value[i.sourceCode]);
                  });
                }
              });

              _this3.setState({
                lastUpdateUnit: "".concat(code).concat(name)
              });
            }, false);
            dataSet.addEventListener('load', function () {
              fields.forEach(function (item) {
                var _item$conditionHeader2 = item.conditionHeaderDTOs,
                    conditionHeaderDTOs = _item$conditionHeader2 === void 0 ? [] : _item$conditionHeader2,
                    fieldCode = item.fieldCode,
                    _item$conValidDTO2 = item.conValidDTO,
                    conValidDTO = _item$conValidDTO2 === void 0 ? {} : _item$conValidDTO2;
                var data = dataSet.current && dataSet.current.toData() || {};

                _this3.setDataMap(code, data);

                var newFieldConfig = getFieldConfig(_objectSpread({
                  required: item.required,
                  editable: item.editable
                }, coverConfig(conditionHeaderDTOs, tools, ['visible'])));
                var validators = selfValidator(conValidDTO, tools);
                var oldFieldConfig = (dataSet.getField(fieldCode) || {}).pristineProps;
                dataSet.addField(fieldCode, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, oldFieldConfig), newFieldConfig), validators), parseProps(_omit(item, ['width', 'fieldName', 'fieldCode', 'fixed', 'renderOptions', 'conditionHeaderDTOs']), _this3.getToolFuns(), oldFieldConfig)));
              });

              _this3.setState({
                lastUpdateUnit: "load".concat(code)
              });
            }, false);
          }

          var proxyFields = [];
          var tempFields = fields.filter(function (i) {
            var originSeq = fieldMap[i.fieldName] && fieldMap[i.fieldName].seq;

            if ((i.formRow === undefined || i.formCol === undefined) && originSeq === undefined) {
              return true;
            }

            var seq = i.formRow * maxCol + i.formCol;
            proxyFields.push(_objectSpread(_objectSpread({}, i), {}, {
              seq: typeof seq === 'number' ? seq : originSeq
            }));
            return false;
          });
          proxyFields.sort(function (p, n) {
            return p.seq - n.seq;
          });
          var newChildren = [];
          proxyFields.concat(tempFields).forEach(function (item) {
            var fieldCode = item.fieldCode,
                fieldName = item.fieldName,
                renderOptions = item.renderOptions,
                conditionHeaderDTOs = item.conditionHeaderDTOs,
                renderRule = item.renderRule,
                colSpan = item.colSpan,
                _item$conValidDTO3 = item.conValidDTO,
                conValidDTO = _item$conValidDTO3 === void 0 ? {} : _item$conValidDTO3,
                otherProps = _objectWithoutProperties(item, _excluded);

            var oldChild = fieldMap.get(fieldCode);

            var _coverConfig = coverConfig(conditionHeaderDTOs, tools),
                _coverConfig$visible = _coverConfig.visible,
                visible = _coverConfig$visible === void 0 ? item.visible : _coverConfig$visible,
                _coverConfig$required = _coverConfig.required,
                required = _coverConfig$required === void 0 ? item.required : _coverConfig$required,
                _coverConfig$editable = _coverConfig.editable,
                editable = _coverConfig$editable === void 0 ? item.editable : _coverConfig$editable;

            var validators = selfValidator(conValidDTO, tools);
            var newFieldConfig = getFieldConfig({
              visible: visible,
              required: required,
              editable: editable
            });

            if (fieldName !== undefined) {
              newFieldConfig.label = fieldName;
            }

            var oldFieldConfig = (dataSet.getField(fieldCode) || {}).pristineProps;
            dataSet.addField(fieldCode, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, oldFieldConfig), newFieldConfig), validators), parseProps(otherProps, tools, oldFieldConfig)));

            if (visible !== 0 && visible !== undefined) {
              // 做新增扩展字段处理
              if (!oldChild && visible !== -1) {
                if (readOnly || renderOptions === 'TEXT') {
                  var outputProps = {
                    name: fieldCode,
                    label: fieldName,
                    colSpan: colSpan
                  };

                  if (item.fieldType === 'DATE_PICKER') {
                    outputProps.renderer = function (_ref3) {
                      var value = _ref3.value;
                      return value && moment(value).format(item.dateFormat);
                    };
                  }

                  if (!_isNil(renderRule)) {
                    var renderer = function renderer() {
                      return (
                        /*#__PURE__*/
                        // eslint-disable-next-line react/no-danger
                        React.createElement("div", {
                          dangerouslySetInnerHTML: {
                            __html: template.render(renderRule, unitData)
                          }
                        })
                      );
                    };

                    newChildren.push( /*#__PURE__*/React.createElement(_Output, Object.assign({}, outputProps, {
                      renderer: renderer
                    })));
                  } else {
                    newChildren.push( /*#__PURE__*/React.createElement(_Output, outputProps));
                  }
                } else {
                  newChildren.push(getComponent(item.fieldType, {
                    currentData: dataSet.toData()
                  })(_objectSpread({
                    name: fieldCode,
                    label: fieldName
                  }, transformCompProps(otherProps))));
                }
              } else if (oldChild) {
                if (item.editable !== -1) {
                  oldChild.item.props.disabled = !item.editable;
                }

                if (colSpan) {
                  oldChild.item.props.colSpan = colSpan;
                }

                if (item.placeholder !== undefined) {
                  oldChild.item.props.placeholder = item.placeholder;
                }

                newChildren.push(oldChild.item);
              }
            }

            fieldMap.delete(fieldCode);
          });

          if (dataSet.all.length === 0) {
            dataSet.create();
          }

          newChildren = newChildren.concat(Array.from(fieldMap.values()).map(function (i) {
            return i.item;
          }));
          proxyForm.props.children = newChildren;
          proxyForm.props.columns = maxCol;
          return form;
        }
      }, {
        key: "customizeTable",
        value: function customizeTable() {
          var _this4 = this;

          var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
          var table = arguments.length > 1 ? arguments[1] : undefined;
          var _this$state2 = this.state,
              _this$state2$custConf = _this$state2.custConfig,
              custConfig = _this$state2$custConf === void 0 ? {} : _this$state2$custConf,
              _this$state2$loading = _this$state2.loading,
              loading = _this$state2$loading === void 0 ? false : _this$state2$loading,
              cacheType = _this$state2.cacheType;
          var _options$code2 = options.code,
              code = _options$code2 === void 0 ? '' : _options$code2,
              _options$filterCode = options.filterCode,
              filterCode = _options$filterCode === void 0 ? '' : _options$filterCode,
              readOnly1 = options.readOnly;
          var _table$props$dataSet = table.props.dataSet,
              dataSet = _table$props$dataSet === void 0 ? {} : _table$props$dataSet;
          var _table$props$columns = table.props.columns,
              columns = _table$props$columns === void 0 ? [] : _table$props$columns;
          var fieldMap = new Map(); // 记录已配置的字段

          columns.forEach(function (item) {
            fieldMap.set(item.name, item);
          });

          if (!code || _isEmpty(custConfig[code])) {
            return table;
          }

          if (loading) {
            return /*#__PURE__*/React.createElement(_Spin, {
              spinning: this.state.loading
            }, /*#__PURE__*/React.createElement(_Table, {
              dataSet: new _DataSet(),
              columns: []
            }));
          }

          var unitConfig = custConfig[code] || {};
          var _unitConfig$unitAlias = unitConfig.unitAlias,
              unitAlias = _unitConfig$unitAlias === void 0 ? [] : _unitConfig$unitAlias,
              pageSize = unitConfig.pageSize,
              _unitConfig$fields = unitConfig.fields,
              fields = _unitConfig$fields === void 0 ? [] : _unitConfig$fields,
              readOnly2 = unitConfig.readOnly;
          var readOnly = readOnly1 | readOnly2;
          var queryFieldsLimit = table.props.queryFieldsLimit;
          var queryFields = {};

          if (dataSet.toData) {
            var newData = dataSet.toData() || [];
            newData.forEach(function (item, index) {
              _this4.setArrayDataMap(code, item, index);
            });
          }

          var tools = this.getToolFuns();
          var unitData = getFieldValueObject(unitAlias, tools);

          if (!_isEmpty(custConfig[filterCode])) {
            var _custConfig$filterCod = custConfig[filterCode],
                _custConfig$filterCod2 = _custConfig$filterCod.fields,
                filterFields = _custConfig$filterCod2 === void 0 ? [] : _custConfig$filterCod2,
                maxCol = _custConfig$filterCod.maxCol,
                _custConfig$filterCod3 = _custConfig$filterCod.unitAlias,
                unitFilterAlias = _custConfig$filterCod3 === void 0 ? [] : _custConfig$filterCod3;
            filterFields.sort(function (before, after) {
              return before.seq - after.seq;
            });
            var _dataSet$props$queryD = dataSet.props.queryDataSet,
                queryDataSet = _dataSet$props$queryD === void 0 ? {} : _dataSet$props$queryD;

            var reCreateDs = _isEmpty(queryDataSet);

            if (!cacheType[filterCode]) {
              cacheType[filterCode] = 'form';

              if (!reCreateDs && !queryDataSet.reCreateDs) {
                queryDataSet.addEventListener('load', function (_ref4) {
                  var record = _ref4.record,
                      value = _ref4.value,
                      name = _ref4.name;

                  _this4.setDataMap(filterCode, record.toData());

                  filterFields.forEach(function (item) {
                    var fieldCode = item.fieldCode,
                        _item$lovMappings2 = item.lovMappings,
                        lovMappings = _item$lovMappings2 === void 0 ? [] : _item$lovMappings2;

                    if (lovMappings.length > 0 && name === fieldCode && typeof value === 'object') {
                      lovMappings.forEach(function (i) {
                        record.set(i.targetCode, value[i.sourceCode]);
                      });
                    }
                  });

                  _this4.setState({
                    lastUpdateUnit: "".concat(filterCode).concat(name)
                  });
                }, false);
              }
            }

            var searchFields = []; // 用于重新创建ds

            var oldQueryFieldsMap = {};
            var oldQueryFields = queryDataSet.fields;

            if (!_isEmpty(oldQueryFields)) {
              var fieldObj = oldQueryFields.toJSON();
              Object.keys(fieldObj).forEach(function (i) {
                oldQueryFieldsMap[i] = fieldObj[i].pristineProps;
              });
            }

            filterFields.forEach(function (item) {
              var fieldCode = item.fieldCode,
                  fieldName = item.fieldName,
                  renderOptions = item.renderOptions,
                  visible = item.visible,
                  renderRule = item.renderRule,
                  others = _objectWithoutProperties(item, _excluded2);

              var oldConfig = oldQueryFieldsMap[fieldCode];

              var config = _objectSpread(_objectSpread({}, oldConfig), {}, {
                name: fieldCode
              });

              Object.assign(config, parseProps(item, tools, oldConfig), getFieldConfig(item));

              if (fieldName !== undefined) {
                config.label = fieldName;
              }

              var noOldElement = !oldQueryFieldsMap[fieldCode] && visible === 1; // 排除代码中不存在且显示属性为-1的情况

              var updateConfig = oldQueryFieldsMap[fieldCode] && visible !== 0 || noOldElement;

              if (updateConfig) {
                searchFields.push(config);
              }

              if (!reCreateDs && updateConfig) {
                queryDataSet.addField(fieldCode, config);
              }

              if (noOldElement) {
                if (renderOptions === 'TEXT') {
                  if (!_isNil(renderRule)) {
                    var renderer = function renderer() {
                      var unitFilterData = getFieldValueObject(unitFilterAlias, tools, filterCode); // eslint-disable-next-line react/no-danger

                      return /*#__PURE__*/React.createElement("div", {
                        dangerouslySetInnerHTML: {
                          __html: template.render(renderRule, unitFilterData)
                        }
                      });
                    };

                    queryFields[fieldCode] = /*#__PURE__*/React.createElement(_Output, {
                      name: fieldCode,
                      label: fieldName,
                      renderer: renderer
                    });
                  } else {
                    queryFields[fieldCode] = /*#__PURE__*/React.createElement(_Output, {
                      name: fieldCode,
                      label: fieldName
                    });
                  }
                } else {
                  queryFields[fieldCode] = getComponent(item.fieldType, {
                    currentData: reCreateDs ? {} : queryDataSet.toData()
                  })(transformCompProps(others));
                } // eslint-disable-next-line no-param-reassign


                table.props.queryFields = _objectSpread(_objectSpread({}, table.props.queryFields), queryFields);
              }

              if (oldQueryFieldsMap[fieldCode] && visible === 0) {
                reCreateDs = true;
              }

              delete oldQueryFieldsMap[fieldCode];
            });
            var events = {
              update: function update(_ref5) {
                var record = _ref5.record,
                    value = _ref5.value,
                    name = _ref5.name;

                _this4.setDataMap(filterCode, record.toData());

                filterFields.forEach(function (item) {
                  var fieldCode = item.fieldCode,
                      _item$lovMappings3 = item.lovMappings,
                      lovMappings = _item$lovMappings3 === void 0 ? [] : _item$lovMappings3;

                  if (lovMappings.length > 0 && name === fieldCode && typeof value === 'object') {
                    lovMappings.forEach(function (i) {
                      record.set(i.targetCode, value[i.sourceCode]);
                    });
                  }
                });

                _this4.setState({
                  lastUpdateUnit: "".concat(filterCode).concat(name)
                });
              }
            };

            if (reCreateDs) {
              dataSet.queryDataSet = new _DataSet({
                fields: searchFields.concat(Object.values(oldQueryFieldsMap)),
                events: events
              });
              dataSet.queryDataSet.reCreateDs = true;
            }

            if (dataSet.queryDataSet.all.length === 0) {
              dataSet.queryDataSet.create();
            }

            if (!dataSet.queryDataSet.customize) {
              dataSet.queryDataSet.reset();
            }

            dataSet.queryDataSet.customize = true;
            queryFieldsLimit = maxCol;
          }

          if (pageSize) {
            dataSet.pageSize = pageSize;
          }

          if (!cacheType[code]) {
            cacheType[code] = 'table';
            dataSet.addEventListener('update', function (_ref6) {
              var record = _ref6.record,
                  value = _ref6.value,
                  name = _ref6.name;

              _this4.setArrayDataMap(code, record.toData(), record.index);

              fields.forEach(function (item) {
                var _item$conditionHeader3 = item.conditionHeaderDTOs,
                    conditionHeaderDTOs = _item$conditionHeader3 === void 0 ? [] : _item$conditionHeader3,
                    fieldCode = item.fieldCode,
                    _item$lovMappings4 = item.lovMappings,
                    lovMappings = _item$lovMappings4 === void 0 ? [] : _item$lovMappings4,
                    _item$conValidDTO4 = item.conValidDTO,
                    conValidDTO = _item$conValidDTO4 === void 0 ? {} : _item$conValidDTO4;

                var _coverConfig2 = coverConfig(conditionHeaderDTOs, _objectSpread(_objectSpread({}, tools), {}, {
                  index: record.index,
                  code: code
                }), ['visible']),
                    _coverConfig2$require = _coverConfig2.required,
                    required = _coverConfig2$require === void 0 ? item.required : _coverConfig2$require,
                    _coverConfig2$editabl = _coverConfig2.editable,
                    editable = _coverConfig2$editabl === void 0 ? item.editable : _coverConfig2$editabl;

                var newFieldConfig = getFieldConfig({
                  required: required,
                  editable: editable
                });
                var validators = selfValidator(conValidDTO, _objectSpread(_objectSpread({}, _this4.getToolFuns()), {}, {
                  index: record.index,
                  code: code
                }));
                var oldFieldConfig = (record.getField(fieldCode) || {}).pristineProps;
                record.addField(fieldCode, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, oldFieldConfig), newFieldConfig), parseProps(_omit(item, ['width', 'fieldName', 'fieldCode', 'fixed', 'renderOptions', 'conditionHeaderDTOs']), _objectSpread(_objectSpread({}, tools), {}, {
                  index: record.index,
                  code: code
                }), oldFieldConfig)), validators));

                if (lovMappings.length > 0 && name === fieldCode && typeof value === 'object') {
                  lovMappings.forEach(function (i) {
                    record.set(i.targetCode, value[i.sourceCode]);
                  });
                }
              });

              _this4.setState({
                lastUpdateUnit: "".concat(code).concat(name)
              });
            }, false);
            dataSet.addEventListener('load', function (_ref7) {
              var ds = _ref7.dataSet;
              (ds.records || []).forEach(function (item, index) {
                _this4.setArrayDataMap(code, item.toData(), item.index);

                fields.forEach(function (i) {
                  var _i$conditionHeaderDTO = i.conditionHeaderDTOs,
                      conditionHeaderDTOs = _i$conditionHeaderDTO === void 0 ? [] : _i$conditionHeaderDTO,
                      fieldCode = i.fieldCode,
                      _i$conValidDTO = i.conValidDTO,
                      conValidDTO = _i$conValidDTO === void 0 ? {} : _i$conValidDTO;

                  var _coverConfig3 = coverConfig(conditionHeaderDTOs, _objectSpread(_objectSpread({}, tools), {}, {
                    index: index,
                    code: code
                  }), ['visible']),
                      _coverConfig3$require = _coverConfig3.required,
                      required = _coverConfig3$require === void 0 ? i.required : _coverConfig3$require,
                      _coverConfig3$editabl = _coverConfig3.editable,
                      editable = _coverConfig3$editabl === void 0 ? i.editable : _coverConfig3$editabl;

                  var newFieldConfig = getFieldConfig({
                    required: required,
                    editable: editable
                  });
                  var validators = selfValidator(conValidDTO, _objectSpread(_objectSpread({}, tools), {}, {
                    index: index,
                    code: code
                  }));
                  var oldFieldConfig = (item.getField(fieldCode) || {}).pristineProps;
                  item.addField(fieldCode, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, oldFieldConfig), newFieldConfig), parseProps(_omit(i, ['width', 'fieldName', 'fieldCode', 'fixed', 'renderOptions', 'conditionHeaderDTOs']), _objectSpread(_objectSpread({}, tools), {}, {
                    index: index,
                    code: code
                  }), oldFieldConfig)), validators));
                });
              });

              _this4.setState({
                lastUpdateUnit: "load".concat(code)
              });
            }, false);
          }

          if (fields && fields.length > 0) {
            // 根据列顺序属性排序
            fields.sort(function (before, after) {
              return before.seq - after.seq;
            }); // 左固定前置， 右固定后置

            var leftFixedColumns = fields.filter(function (item) {
              return item.fixed === 'L';
            });
            var rightFixedColumns = fields.filter(function (item) {
              return item.fixed === 'R';
            });
            var centerFixedColumns = fields.filter(function (item) {
              return item.fixed !== 'L' && item.fixed !== 'R';
            });
            var newFields = leftFixedColumns.concat(centerFixedColumns).concat(rightFixedColumns);
            var newColumns = [];
            newFields.forEach(function (item) {
              var width = item.width,
                  fieldName = item.fieldName,
                  fieldCode = item.fieldCode,
                  fixed = item.fixed,
                  renderOptions = item.renderOptions,
                  conditionHeaderDTOs = item.conditionHeaderDTOs,
                  renderRule = item.renderRule,
                  _item$conValidDTO5 = item.conValidDTO,
                  conValidDTO = _item$conValidDTO5 === void 0 ? {} : _item$conValidDTO5,
                  fieldType = item.fieldType;
              var oldCol = fieldMap.get(fieldCode);
              if (!oldCol && item.visible === -1) return;

              var _coverConfig4 = coverConfig(conditionHeaderDTOs, _objectSpread(_objectSpread({}, tools), {}, {
                code: code
              }), ['editable', 'required']),
                  _coverConfig4$visible = _coverConfig4.visible,
                  visible = _coverConfig4$visible === void 0 ? item.visible : _coverConfig4$visible,
                  _coverConfig4$require = _coverConfig4.required,
                  required = _coverConfig4$require === void 0 ? item.required : _coverConfig4$require,
                  _coverConfig4$editabl = _coverConfig4.editable,
                  editable = _coverConfig4$editabl === void 0 ? item.editable : _coverConfig4$editabl;

              var newFieldConfig = getFieldConfig({
                visible: visible,
                required: required,
                editable: editable
              }); // ds配置覆盖

              var validators = selfValidator(conValidDTO, _objectSpread(_objectSpread({}, tools), {}, {
                code: code
              }));

              var newColumnsConfig = _objectSpread({
                name: fieldCode
              }, getColumnsConfig({
                fixed: fixed,
                width: width,
                visible: visible
              })); // 原表格columns配置覆盖


              if (fieldName !== undefined) {
                newFieldConfig.label = fieldName;
                newColumnsConfig.header = fieldName;
              }

              if (oldCol && oldCol.header) {
                if (typeof oldCol.header === 'function') {
                  newColumnsConfig.header = function (records, name) {
                    return oldCol.header(records, fieldName, name);
                  };
                } else if (typeof oldCol.header === 'object') {
                  newColumnsConfig.header = oldCol.header;
                }
              }

              var oldFieldConfig = (dataSet.getField(fieldCode) || {}).pristineProps;
              dataSet.addField(fieldCode, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, oldFieldConfig), newFieldConfig), parseProps(item, tools, oldFieldConfig)), validators));

              if (!oldCol) {
                var formFieldGen = function formFieldGen(record) {
                  return getComponent(item.fieldType, {
                    currentData: record.toData()
                  })(transformCompProps(item));
                };

                newColumnsConfig.editor = false;

                if (readOnly || renderOptions === 'TEXT') {
                  if (!_isNil(renderRule)) {
                    newColumnsConfig.renderer = function (line) {
                      return (
                        /*#__PURE__*/
                        // eslint-disable-next-line react/no-danger
                        React.createElement("div", {
                          // eslint-disable-next-line react/no-danger
                          dangerouslySetInnerHTML: {
                            __html: template.render(renderRule, _objectSpread(_objectSpread({}, unitData), {}, {
                              self: line.record.toData()
                            }))
                          }
                        })
                      );
                    };
                  } else if (fieldType === 'DATE_PICKER') {
                    newColumnsConfig.renderer = function (_ref8) {
                      var value = _ref8.value;
                      return value && moment(value).format(item.dateFormat);
                    };
                  }
                } else if (fieldType === 'LINK') {
                  newColumnsConfig.renderer = function (line) {
                    return formFieldGen(line.record);
                  };
                } else {
                  newColumnsConfig.editor = formFieldGen;
                }
              }

              fieldMap.delete(fieldCode);
              newColumns.push(_objectSpread(_objectSpread({}, oldCol), newColumnsConfig));
            }); // 代码中而配置中没有的字段

            columns = newColumns.concat(Array.from(fieldMap.values()));
          }

          var proxyTableProps = table.props || {};
          proxyTableProps.columns = columns;
          proxyTableProps.queryFieldsLimit = queryFieldsLimit;
          return table;
        }
      }, {
        key: "customizeVTable",
        value: function customizeVTable() {
          var _this5 = this;

          var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
          var table = arguments.length > 1 ? arguments[1] : undefined;
          var _this$state3 = this.state,
              _this$state3$custConf = _this$state3.custConfig,
              custConfig = _this$state3$custConf === void 0 ? {} : _this$state3$custConf,
              _this$state3$loading = _this$state3.loading,
              loading = _this$state3$loading === void 0 ? false : _this$state3$loading,
              cacheType = _this$state3.cacheType,
              cacheTable = _this$state3.cacheTable;
          var _options$code3 = options.code,
              code = _options$code3 === void 0 ? '' : _options$code3,
              _options$dataSet = options.dataSet,
              dataSet = _options$dataSet === void 0 ? {} : _options$dataSet,
              readOnly1 = options.readOnly;
          var _table$props$columns2 = table.props.columns,
              columns = _table$props$columns2 === void 0 ? [] : _table$props$columns2;
          var fieldMap = {}; // 记录已配置的字段

          if (!code || _isEmpty(custConfig[code])) {
            return table;
          }

          if (loading) {
            return /*#__PURE__*/React.createElement(_Spin, {
              spinning: this.state.loading
            }, /*#__PURE__*/React.createElement(_Table, {
              dataSet: new _DataSet(),
              columns: []
            }));
          }

          var unitConfig = custConfig[code] || {};
          var _unitConfig$unitAlias2 = unitConfig.unitAlias,
              unitAlias = _unitConfig$unitAlias2 === void 0 ? [] : _unitConfig$unitAlias2,
              _unitConfig$fields2 = unitConfig.fields,
              fields = _unitConfig$fields2 === void 0 ? [] : _unitConfig$fields2,
              readOnly2 = unitConfig.readOnly;
          var tools = this.getToolFuns();
          var unitData = getFieldValueObject(unitAlias, tools);
          var updateColumns = false;

          if (!cacheType[code]) {
            cacheType[code] = 'table';
            (dataSet.toData() || []).newData.forEach(function (item, index) {
              _this5.setArrayDataMap(code, item, index);
            });
            dataSet.addEventListener('update', function (_ref9) {
              var record = _ref9.record,
                  value = _ref9.value,
                  name = _ref9.name;

              _this5.setArrayDataMap(code, record.toData(), record.index);

              fields.forEach(function (item) {
                var _item$conditionHeader4 = item.conditionHeaderDTOs,
                    conditionHeaderDTOs = _item$conditionHeader4 === void 0 ? [] : _item$conditionHeader4,
                    fieldCode = item.fieldCode,
                    _item$lovMappings5 = item.lovMappings,
                    lovMappings = _item$lovMappings5 === void 0 ? [] : _item$lovMappings5,
                    _item$conValidDTO6 = item.conValidDTO,
                    conValidDTO = _item$conValidDTO6 === void 0 ? {} : _item$conValidDTO6;

                var _coverConfig5 = coverConfig(conditionHeaderDTOs, _objectSpread(_objectSpread({}, tools), {}, {
                  index: record.index,
                  code: code
                }), ['visible']),
                    _coverConfig5$require = _coverConfig5.required,
                    required = _coverConfig5$require === void 0 ? item.required : _coverConfig5$require,
                    _coverConfig5$editabl = _coverConfig5.editable,
                    editable = _coverConfig5$editabl === void 0 ? item.editable : _coverConfig5$editabl;

                var newFieldConfig = getFieldConfig({
                  required: required,
                  editable: editable
                });
                var validators = selfValidator(conValidDTO, _objectSpread(_objectSpread({}, _this5.getToolFuns()), {}, {
                  index: record.index,
                  code: code
                }));
                var oldFieldConfig = (record.getField(fieldCode) || {}).pristineProps;
                record.addField(fieldCode, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, oldFieldConfig), newFieldConfig), parseProps(_omit(item, ['width', 'fieldName', 'fieldCode', 'fixed', 'renderOptions', 'conditionHeaderDTOs']), _objectSpread(_objectSpread({}, tools), {}, {
                  index: record.index,
                  code: code
                }), oldFieldConfig)), validators));

                if (lovMappings.length > 0 && name === fieldCode && typeof value === 'object') {
                  lovMappings.forEach(function (i) {
                    record.set(i.targetCode, value[i.sourceCode]);
                  });
                }
              });

              _this5.setState({
                lastUpdateUnit: "".concat(code).concat(name)
              });
            }, false);
            dataSet.addEventListener('load', function (_ref10) {
              var ds = _ref10.dataSet;
              (ds.records || []).forEach(function (item, index) {
                _this5.setArrayDataMap(code, item.toData(), item.index);

                fields.forEach(function (i) {
                  var _i$conditionHeaderDTO2 = i.conditionHeaderDTOs,
                      conditionHeaderDTOs = _i$conditionHeaderDTO2 === void 0 ? [] : _i$conditionHeaderDTO2,
                      fieldCode = i.fieldCode,
                      _i$conValidDTO2 = i.conValidDTO,
                      conValidDTO = _i$conValidDTO2 === void 0 ? {} : _i$conValidDTO2;

                  var _coverConfig6 = coverConfig(conditionHeaderDTOs, _objectSpread(_objectSpread({}, tools), {}, {
                    index: index,
                    code: code
                  }), ['visible']),
                      _coverConfig6$require = _coverConfig6.required,
                      required = _coverConfig6$require === void 0 ? i.required : _coverConfig6$require,
                      _coverConfig6$editabl = _coverConfig6.editable,
                      editable = _coverConfig6$editabl === void 0 ? i.editable : _coverConfig6$editabl;

                  var newFieldConfig = getFieldConfig({
                    required: required,
                    editable: editable
                  });
                  var validators = selfValidator(conValidDTO, _objectSpread(_objectSpread({}, tools), {}, {
                    index: index,
                    code: code
                  }));
                  var oldFieldConfig = (item.getField(fieldCode) || {}).pristineProps;
                  item.addField(fieldCode, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, oldFieldConfig), newFieldConfig), parseProps(_omit(i, ['width', 'fieldName', 'fieldCode', 'fixed', 'renderOptions', 'conditionHeaderDTOs']), _objectSpread(_objectSpread({}, tools), {}, {
                    index: index,
                    code: code
                  }), oldFieldConfig)), validators));
                });
              });

              _this5.setState({
                lastUpdateUnit: "load".concat(code)
              });
            }, false);
          }

          if (!cacheTable[code]) {
            cacheTable[code] = {
              columns: [],
              hiddenFields: []
            };
            updateColumns = true;
          } else {
            var hiddenFields = cacheTable[code].columns;
            fields.forEach(function (item) {
              var fieldCode = item.fieldCode,
                  conditionHeaderDTOs = item.conditionHeaderDTOs;

              var _coverConfig7 = coverConfig(conditionHeaderDTOs, _objectSpread(_objectSpread({}, tools), {}, {
                code: code
              }), ['editable', 'required']),
                  _coverConfig7$visible = _coverConfig7.visible,
                  visible = _coverConfig7$visible === void 0 ? item.visible : _coverConfig7$visible;

              if (visible === 0 && !hiddenFields.includes(fieldCode)) updateColumns = true;
            });
          }

          cacheTable[code].unitData = unitData;
          columns.forEach(function (item) {
            fieldMap[item.dataIndex] = item;
          });

          if (updateColumns) {
            var readOnly = readOnly1 | readOnly2;
            cacheTable[code].hiddenFields = []; // 根据列顺序属性排序

            fields.sort(function (before, after) {
              return before.seq - after.seq;
            });
            var newColumns = [];
            fields.forEach(function (item) {
              var width = item.width,
                  fieldName = item.fieldName,
                  fieldCode = item.fieldCode,
                  fixed = item.fixed,
                  renderOptions = item.renderOptions,
                  conditionHeaderDTOs = item.conditionHeaderDTOs,
                  renderRule = item.renderRule,
                  _item$conValidDTO7 = item.conValidDTO,
                  conValidDTO = _item$conValidDTO7 === void 0 ? {} : _item$conValidDTO7,
                  fieldType = item.fieldType;
              var oldCol = fieldMap[fieldCode];

              var _coverConfig8 = coverConfig(conditionHeaderDTOs, _objectSpread(_objectSpread({}, tools), {}, {
                code: code
              }), ['editable', 'required']),
                  _coverConfig8$visible = _coverConfig8.visible,
                  visible = _coverConfig8$visible === void 0 ? item.visible : _coverConfig8$visible;

              if (!oldCol && item.visible === -1) return;

              if (visible === 0) {
                cacheTable[code].hiddenFields.push(fieldCode);
                return;
              }

              var newFieldConfig = getFieldConfig({
                visible: visible
              }); // ds配置覆盖

              var validators = selfValidator(conValidDTO, _objectSpread(_objectSpread({}, tools), {}, {
                code: code
              }));

              var newColumnsConfig = _objectSpread({
                dataIndex: fieldCode,
                key: fieldCode,
                resizable: true
              }, getColumnsConfig({
                fixed: fixed,
                width: width,
                visible: visible
              })); // 原表格columns配置覆盖


              if (fieldName !== undefined) {
                newFieldConfig.label = fieldName;
                newColumnsConfig.title = fieldName;
              }

              var oldFieldConfig = (dataSet.getField(fieldCode) || {}).pristineProps;
              dataSet.addField(fieldCode, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, oldFieldConfig), newFieldConfig), parseProps(item, tools, oldFieldConfig)), validators));

              if (!oldCol) {
                var formFieldGen = function formFieldGen(_ref11) {
                  var rowData = _ref11.rowData,
                      rowIndex = _ref11.rowIndex,
                      dataIndex = _ref11.dataIndex;
                  var record = dataSet.get(rowIndex);
                  return getComponent(item.fieldType, {
                    currentData: rowData
                  })(_objectSpread(_objectSpread({}, transformCompProps(item)), {}, {
                    name: dataIndex,
                    record: record
                  }));
                };

                if (readOnly || renderOptions === 'TEXT') {
                  if (!_isNil(renderRule)) {
                    newColumnsConfig.render = function (_ref12) {
                      var rowIndex = _ref12.rowIndex;
                      return (
                        /*#__PURE__*/
                        // eslint-disable-next-line react/no-danger
                        React.createElement("div", {
                          // eslint-disable-next-line react/no-danger
                          dangerouslySetInnerHTML: {
                            __html: template.render(renderRule, _objectSpread(_objectSpread({}, cacheTable[code].unitData), {}, {
                              self: dataSet.get(rowIndex).toData()
                            }))
                          }
                        })
                      );
                    };
                  } else if (fieldType === 'DATE_PICKER') {
                    newColumnsConfig.renderer = function (_ref13) {
                      var rowData = _ref13.rowData,
                          dataIndex = _ref13.dataIndex;
                      return rowData[dataIndex] && moment(rowData[dataIndex]).format(item.dateFormat);
                    };
                  }
                } else {
                  newColumnsConfig.render = formFieldGen;
                }
              }

              delete fieldMap[fieldCode];
              newColumns.push(_objectSpread(_objectSpread({}, oldCol), newColumnsConfig));
            }); // 代码中而配置中没有的字段

            newColumns = newColumns.concat(Object.values(fieldMap)); // 左固定前置， 右固定后置

            var leftFixedColumns = [];
            var rightFixedColumns = [];
            var centerFixedColumns = [];
            newColumns.forEach(function (item) {
              if (item.fixed === 'left' || item.fixed === true) {
                leftFixedColumns.push(item);
              } else if (item.fixed === 'right') {
                rightFixedColumns.push(item);
              } else {
                centerFixedColumns.push(item);
              }
            });
            cacheTable[code].columns = leftFixedColumns.concat(centerFixedColumns).concat(rightFixedColumns);
          }

          return React.cloneElement(table, {
            columns: cacheTable[code].columns
          });
        }
      }, {
        key: "customizeCollapse",
        value: function customizeCollapse() {
          var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
          var collapse = arguments.length > 1 ? arguments[1] : undefined;
          var code = options.code;
          var _this$state4 = this.state,
              config = _this$state4.configModel,
              loading = _this$state4.loading;
          if (loading) return null;
          if (!code || _isEmpty(config[code])) return collapse;
          var _config$code$fields = config[code].fields,
              fields = _config$code$fields === void 0 ? [] : _config$code$fields;
          fields.sort(function (p, n) {
            return p.seq === undefined || n.seq === undefined ? -1 : p.seq - n.seq;
          });
          var childrenMap = {};
          var newChildren = [];
          var refTabs = collapse;
          var refChildren = refTabs.props.children;
          var tools = this.getToolFuns();

          if (_isArray(refChildren)) {
            refChildren.forEach(function (i) {
              if (i.props && i.key !== undefined) {
                childrenMap[i.key] = i;
              }
            });
          } else if (refChildren && refChildren.props && refChildren.key) {
            childrenMap[refChildren.key] = refChildren;
          }

          fields.forEach(function (i) {
            var fieldName = i.fieldName,
                fieldCode = i.fieldCode,
                conditionHeaderDTOs = i.conditionHeaderDTOs;

            var _visible$coverConfig = _objectSpread({
              visible: i.visible
            }, coverConfig(conditionHeaderDTOs, tools, ['required', 'editable'])),
                visible = _visible$coverConfig.visible;

            var targetPane = childrenMap[fieldCode];

            if (fieldName !== undefined && targetPane.props) {
              var oldHeader = targetPane.props.header;

              if (typeof oldHeader === 'function') {
                targetPane.props.header = oldHeader(fieldName);
              } else {
                targetPane.props.header = /*#__PURE__*/React.createElement("h3", null, fieldName);
              }
            }

            if (visible !== 0) {
              newChildren.push(targetPane);
            }

            delete childrenMap[fieldCode];
          });
          Object.keys(childrenMap).forEach(function (i) {
            return newChildren.push(childrenMap[i]);
          });
          refTabs.props.children = newChildren;
          return collapse;
        }
      }, {
        key: "customizeTabPane",
        value: function customizeTabPane() {
          var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
          var tabs = arguments.length > 1 ? arguments[1] : undefined;
          var code = options.code;
          var _this$state5 = this.state,
              config = _this$state5.custConfig,
              loading = _this$state5.loading;
          if (loading) return null;
          if (!code || _isEmpty(config[code])) return tabs;
          var _config$code$fields2 = config[code].fields,
              fields = _config$code$fields2 === void 0 ? [] : _config$code$fields2;
          fields.sort(function (p, n) {
            return p.seq === undefined || n.seq === undefined ? -1 : p.seq - n.seq;
          });
          var childrenMap = {};
          var newChildren = [];
          var refTabs = tabs;
          var refChildren = refTabs.props.children;
          var tools = this.getToolFuns();

          if (_isArray(refChildren)) {
            refChildren.forEach(function (i) {
              if (i.props && i.key !== undefined) {
                childrenMap[i.key] = i;
              }
            });
          } else if (refChildren && refChildren.props && refChildren.key) {
            childrenMap[refChildren.key] = refChildren;
          }

          fields.forEach(function (i) {
            var fieldName = i.fieldName,
                fieldCode = i.fieldCode,
                conditionHeaderDTOs = i.conditionHeaderDTOs;

            var _visible$coverConfig2 = _objectSpread({
              visible: i.visible
            }, coverConfig(conditionHeaderDTOs, tools, ['required', 'editable'])),
                visible = _visible$coverConfig2.visible;

            var targetPane = childrenMap[fieldCode];

            if (fieldName !== undefined && targetPane.props) {
              targetPane.props.tab = fieldName;
            }

            if (visible !== 0) {
              newChildren.push(targetPane);
            }

            delete childrenMap[fieldCode];
          });
          Object.keys(childrenMap).forEach(function (i) {
            return newChildren.push(childrenMap[i]);
          });
          refTabs.props.children = newChildren;
          return tabs;
        }
      }, {
        key: "render",
        value: function render() {
          var _this$state6 = this.state,
              _this$state6$loading = _this$state6.loading,
              loading = _this$state6$loading === void 0 ? true : _this$state6$loading,
              lastUpdateUnit = _this$state6.lastUpdateUnit;

          var newProps = _objectSpread(_objectSpread({}, this.props), {}, {
            custLoading: loading,
            lastUpdateUnit: lastUpdateUnit,
            customizeTable: this.customizeTable,
            customizeVTable: this.customizeVTable,
            customizeForm: this.customizeForm,
            customizeTabPane: this.customizeTabPane,
            queryUnitConfig: this.queryUnitConfig
          });

          return /*#__PURE__*/React.createElement(Component, Object.assign({}, newProps, {
            ref: this.props.forwardRef
          }));
        }
      }]);

      return WrapIndividual;
    }(React.Component), (_applyDecoratedDescriptor(_class.prototype, "setDataMap", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "setDataMap"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "getDataValue", [_dec2], Object.getOwnPropertyDescriptor(_class.prototype, "getDataValue"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "setArrayDataMap", [_dec3], Object.getOwnPropertyDescriptor(_class.prototype, "setArrayDataMap"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "getArrayDataValue", [_dec4], Object.getOwnPropertyDescriptor(_class.prototype, "getArrayDataValue"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "getCacheType", [_dec5], Object.getOwnPropertyDescriptor(_class.prototype, "getCacheType"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "getToolFuns", [_dec6], Object.getOwnPropertyDescriptor(_class.prototype, "getToolFuns"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "queryUnitConfig", [_dec7], Object.getOwnPropertyDescriptor(_class.prototype, "queryUnitConfig"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "customizeForm", [_dec8], Object.getOwnPropertyDescriptor(_class.prototype, "customizeForm"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "customizeTable", [_dec9], Object.getOwnPropertyDescriptor(_class.prototype, "customizeTable"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "customizeVTable", [_dec10], Object.getOwnPropertyDescriptor(_class.prototype, "customizeVTable"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "customizeCollapse", [_dec11], Object.getOwnPropertyDescriptor(_class.prototype, "customizeCollapse"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "customizeTabPane", [_dec12], Object.getOwnPropertyDescriptor(_class.prototype, "customizeTabPane"), _class.prototype)), _class));
    return React.forwardRef(function (props, ref) {
      return /*#__PURE__*/React.createElement(WrapIndividual, Object.assign({}, props, {
        forwardRef: ref
      }));
    });
  };
}

function getFieldConfig(_ref14) {
  var required = _ref14.required,
      editable = _ref14.editable,
      visible = _ref14.visible;
  var newFieldConfig = {
    visible: visible
  };

  if (required !== -1) {
    newFieldConfig.required = !!required;
  }

  if (visible === 0) {
    newFieldConfig.required = false;
  }

  if (editable !== -1 && !_isNil(editable)) {
    newFieldConfig.disabled = !editable;
  }

  return newFieldConfig;
}

function getColumnsConfig(_ref15) {
  var visible = _ref15.visible,
      fixed = _ref15.fixed,
      width = _ref15.width;
  var newColumnsConfig = {};

  if (visible !== -1) {
    newColumnsConfig.hidden = !visible;
  }

  if (fixed === 'L') {
    newColumnsConfig.lock = 'left';
  } else if (fixed === 'R') {
    newColumnsConfig.lock = 'right';
  }

  if (width !== undefined) {
    newColumnsConfig.width = width;
  }

  return newColumnsConfig;
}